package com.sun.listener;

import com.sun.listener.event.MyEvent;
import com.sun.pojo.Student;
import org.springframework.context.ApplicationListener;
import org.springframework.stereotype.Component;

@Component
public class MyEventListener implements ApplicationListener<MyEvent> {
    @Override
    public void onApplicationEvent(MyEvent event) {
        //获取事件中的信息
        Student student = event.getStudent();
        System.out.println("打印学生名字:"+student.getName());
        System.out.println("打印学生的id:"+student.getId());
    }
}
